package com.allwees.bs.module.oms.vo;

import com.allwees.bs.module.oms.entity.OmsOrder;
import lombok.Data;
import me.zhengjie.utils.StringUtils;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class OrderWithStatVo {
    private String uuid;
    private String no;
    private BigDecimal amt;
    private BigDecimal amtProduct;
    private Date paymentAt;
    private BigDecimal amtShipping;
    private Integer refundCount;
    private String categoryFullName;

    private String userName;
    private String userUuid;
    private String addressLine1;
    private String addressLine2;

    public OrderWithStatVo(OmsOrder order) {
        this.uuid = order.getUuid();
        this.no = order.getNo();
        this.amt = order.getAmt();
        this.amtProduct = order.getAmtProduct();
        this.paymentAt = order.getPaymentAt();
        this.amtShipping = order.getAmtShipping();
        this.refundCount = order.getRefundCount();

        this.userName = order.getShippingAddressFirstName() + " " + order.getShippingAddressLastName();
        this.userUuid = order.getUserUuid();
        this.addressLine1 = StringUtils.isEmpty(order.getShippingAddressLine1()) ? "" : order.getShippingAddressLine1();
        this.addressLine2 = StringUtils.isEmpty(order.getShippingAddressLine2()) ? "" : order.getShippingAddressLine2();
    }

    public void setCategoryFullName(String categoryFullName) {
        if (StringUtils.isBlank(categoryFullName)) {
            return;
        }
        if (categoryFullName.endsWith(",")) {
            categoryFullName = categoryFullName.substring(0, categoryFullName.length() - 1);
        }
        this.categoryFullName = categoryFullName;
    }
}
